<?php
class cmshopapi_GetSessionID extends cmshopApi_base
{
    var $verb='GetSessionID';
    var $fields=array(
        
    );
    function Request(){
        if($this->input['RuName']=='GetSessionID'){
        // 生成 session 
            $sessionid=$this->_lengcode($this->appclient['app_id'],7,'time').'-'.$this->_lengcode($this->appclient['app_cert'],12,'time');
            $s=new Sessionid();
            $s->app_id=$this->appclient['app_id'];
            $s->sessionid=$sessionid;
            $s->type='authtoken';
            $s->hardexpirationtime= CURRENT_TIMESTAMP +1800;
            $s->save();
            die($this->Response($sessionid,$s->hardexpirationtime));
        }
        return false;
    }
    
    // 回给 客户  .
    function Response($sessionid,$hardexpirationtime){
		$xmlArr=array(
            'Ack'=>'Success',
            'timestamp'=>$this->dateTime(),
		) +array(
			'SessionID'=>$sessionid,
			'hardexpirationtime'=>$hardexpirationtime
		);
        return $this->xmlresponse($xmlArr);
    }
    
}